import java.util.PriorityQueue;
import java.util.Scanner;

public class Test03 {


        public static Long getMax(Long[] arr, int left, int right) {
            if (left == arr.length) {
                return 0L;
            }
            long max = arr[left];
            for (int i = left; i < right + 1; i++) {
                if (max < arr[i]) {
                    max = arr[i];
                }
            }
            return max;
        }

        public static Long getMin(Long[] arr, int left, int right) {
            if (left == arr.length) {
                return 0L;
            }
            long min = arr[left];
            for (int i = left; i < right + 1; i++) {
                if (min > arr[i]) {
                    min = arr[i];
                }
            }
            return min;
        }
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            Long[] arr = new Long[n];
            Long[] acc = new Long[n];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = in.nextLong();
            }
            for (int i = 1; i < arr.length; i++) {
                Long leftMax = getMax(arr, 0, i);
                Long leftMin = getMin(arr, 0, i);
                Long rightMax = getMax(arr, i + 1, arr.length - 1);
                Long rightMin = getMin(arr, i + 1, arr.length - 1);
                acc[i] = Math.abs((leftMax - leftMin) - (rightMax - rightMin));
            }
            Long[] app = new Long[acc.length - 1];
            System.arraycopy(acc, 1, app, 0, app.length);
            PriorityQueue<Long> queue = new PriorityQueue<>();
            for (int i = 0; i < app.length; i++) {
                queue.add(app[i]);
            }
            System.out.println(queue.peek());
        }

    }

